<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>
<head>
  <title>authenticate (SpreadsheetExamples)</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
</head>
<body class="standalone-code">
  <pre><span class="ruby-comment cmt"># File SpreadsheetExamples.rb, line 54</span>
  <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">authenticate</span>(<span class="ruby-identifier">email</span>, <span class="ruby-identifier">password</span>)
    <span class="ruby-identifier">http</span> = <span class="ruby-constant">Net</span><span class="ruby-operator">::</span><span class="ruby-constant">HTTP</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value str">'www.google.com'</span>, <span class="ruby-value">443</span>)
    <span class="ruby-identifier">http</span>.<span class="ruby-identifier">use_ssl</span> = <span class="ruby-keyword kw">true</span>
    <span class="ruby-identifier">path</span> = <span class="ruby-value str">'/accounts/ClientLogin'</span>
    <span class="ruby-identifier">data</span> = <span class="ruby-node">&quot;accountType=HOSTED_OR_GOOGLE&amp;Email=#{email}&quot;</span> \
        <span class="ruby-node">&quot;&amp;Passwd=#{password}&amp;service=wise&quot;</span>
    <span class="ruby-ivar">@headers</span> = { <span class="ruby-value str">'Content-Type'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-constant">CONTENT_TYPE_FORM</span> }
    <span class="ruby-identifier">resp</span>, <span class="ruby-identifier">data</span> = <span class="ruby-identifier">http</span>.<span class="ruby-identifier">post</span>(<span class="ruby-identifier">path</span>, <span class="ruby-identifier">data</span>, <span class="ruby-identifier">headers</span>)
    <span class="ruby-identifier">cl_string</span> = <span class="ruby-identifier">data</span>[<span class="ruby-regexp re">/Auth=(.*)/</span>, <span class="ruby-value">1</span>]
    <span class="ruby-ivar">@headers</span>[<span class="ruby-value str">&quot;Authorization&quot;</span>] = <span class="ruby-node">&quot;GoogleLogin auth=#{cl_string}&quot;</span>
  <span class="ruby-keyword kw">end</span></pre>
</body>
</html>